package com.walle.ak47.commons.jaxrs;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.ext.ExceptionMapper;

import com.walle.ak47.commons.jaxrs.exception.BizException;

public class BizExceptionMapper implements ExceptionMapper<BizException> {

	@Override
	public Response toResponse(BizException ex) {
		ResponseBuilder rb = Response.status(Response.Status.OK);
		BaseResp data = new BaseResp();
		data.setStatus(ex.getCode());
		data.setReason(ex.getMessage());
		rb.entity(data);
		Response r = rb.build();
		return r;
	}

}
